package data;

import java.util.Arrays;

import map.MapData;

public class DataHandler {

	public static void handle(byte[] recvdata) {
		// TODO check if packet length is correct
		short len = (short)(recvdata.length-3);
		//Raw data without header
		byte[] data = Arrays.copyOfRange(recvdata, 3, recvdata.length);
		//switch data types and process
		switch(recvdata[2]) {
		//Login
			case Data.AUTH:
				System.out.println("Login OK");
				break;
		//Message
			case Data.MESSAGE:
				new Message(data).process(len);
				break;
		//MapData
			case Data.MAP_DATA:
				new MapData(data).process(len);
				break;
		//Default
			default: 
				System.out.println("Da kann ich nix mit anfangen");
				break;
		}
		
	}
	
	
	private DataHandler() {
	}

}
